package com.aspose.cells;

import java.util.ArrayList;

class zqz {
   private zuy a;
   private zra b;
   private ArrayList c;
   private int d;

   zqz(zra var1) {
      this.b = var1;
      this.c = new ArrayList();
      this.a = new zuy();
   }

   void a(zqz var1) {
      this.a.a(var1.a);
      this.d = var1.d;
      this.c.clear();

      for(int var2 = 0; var2 < var1.c.size(); ++var2) {
         zva var3 = (zva)var1.c.get(var2);
         zva var4 = new zva();
         var4.a(var3);
         com.aspose.cells.b.a.a.ze.a(this.c, (Object)var4);
      }

   }

   int a() {
      int var1 = 16 + this.c.size() * 8;
      return var1;
   }

   zuy b() {
      return this.a;
   }

   ArrayList c() {
      return this.c;
   }

   int d() {
      return this.d;
   }

   void a(int var1) {
      this.d = var1;
   }

   zqy a(ShapeCollection var1, zra var2) {
      ++this.d;
      zva var3 = new zva();
      var3.a = this.d & '\uffff';
      var3.b = 1;
      com.aspose.cells.b.a.a.ze.a(this.c(), (Object)var3);
      int var4 = this.c.size() * 1024 + 1;
      if (var4 < this.b().a) {
         int var5 = (int)Math.ceil((double)(this.b().a - 1) / 1024.0D);
         if (var5 > this.c.size()) {
            var4 = (this.b().a / 1024 + 1) * 1024 + 1;
         }
      }

      this.b().a = var4;
      this.b().c = 1;
      this.b().b = 1;
      zqy var6 = new zqy(var1, var2, this.d & '\uffff', this.b().a - 1);
      return var6;
   }

   int a(int var1, int var2) {
      for(int var3 = this.c.size() - 1; var3 >= 0; --var3) {
         zva var4 = (zva)this.c.get(var3);
         if (var4.a == var1) {
            if ((var4.b + var2) / 1024 == 1) {
               var4 = new zva();
               var4.a = var1;
               var4.b = 1;
               com.aspose.cells.b.a.a.ze.a(this.c, (Object)var4);
               int var5 = this.c.size() * 1024 + 1;
               if (var5 < this.b().a) {
                  int var6 = (int)Math.ceil((double)(this.b().a - 1) / 1024.0D);
                  if (var6 > this.c.size()) {
                     var5 = (this.b().a / 1024 + 1) * 1024 + 1;
                  }
               }

               --var5;
               this.b().a = var5;
               return this.b().a;
            }
            break;
         }
      }

      return -1;
   }

   int b(int var1, int var2) {
      zuy var10000 = this.b();
      var10000.b += var2;

      for(int var3 = this.c.size() - 1; var3 >= 0; --var3) {
         zva var4 = (zva)this.c.get(var3);
         if (var4.a == var1) {
            if (var3 == this.c.size() - 1 && this.b().a / 1024 <= this.c.size()) {
               this.b().a = (this.c.size() + 1) * 1024 + 1;
            }

            var4.b += var2;
            if (var2 == 1 && var4.b != 1 && var4.b % 1024 == 1) {
               --var4.b;
               var4 = new zva();
               var4.a = var1;
               var4.b = 1;
               com.aspose.cells.b.a.a.ze.a(this.c, (Object)var4);
               int var5 = this.c.size() * 1024 + 1;
               if (var5 < this.b().a) {
                  int var6 = (int)Math.ceil((double)(this.b().a - 1) / 1024.0D);
                  if (var6 > this.c.size()) {
                     var5 = (this.b().a / 1024 + 1) * 1024 + 1;
                  }
               }

               this.b().a = var5;
               return this.b().a;
            }
            break;
         }
      }

      return -1;
   }
}
